package com.zhao.demo.bound.demo01_srctarget_local

import org.apache.flink.api.scala.ExecutionEnvironment
import org.apache.log4j.{Level, Logger}

/**
 * Description: 计算指定源目录下所有文件中单词出现的次数(源和目的地都是local->本地文件系统)<br/>
 * Copyright (c) ，2020 ， 赵 <br/>
 * This program is protected by copyright laws. <br/>
 * Date： 2020/11/24 15:11
 *
 * @author 柒柒
 * @version : 1.0
 */

object BoundedFlowDemo {
  def main(args: Array[String]): Unit = {

    Logger.getLogger("org").setLevel(Level.WARN)
    //1.执行环境
    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment

    //2.计算,显示,或者保存结果
    //a)导入单例类scala中隐式成员
    import org.apache.flink.api.scala._

    //迭代计算
    env.readTextFile("a_input")
      .flatMap(_.split("\\s+"))
      .filter(_.nonEmpty)
      .map((_,1))
      .groupBy(0)
      .sum(1)
      .print()

  }
}
